﻿requirejs.config({
    baseUrl: ".",
    paths: {
    	zepto:"javascripts/zepto.min",
    	dingtalk:"javascripts/dingtalk",
        vue: "components/vue/vue.min",
        axios: "components/axios/axios.min",
        MINT: "components/mint-ui/index",
        common: "resources/js/common",
        wx: "http://res.wx.qq.com/open/js/jweixin-1.2.0",
        jssdk: "resources/js/jssdk"
    },
    shim: {
        "wx": {
            exports: "wx"
        }
    }
});

require(["zepto","dingtalk","vue", "axios", "common", "jssdk", "MINT"], function (zepto,dingtalk,Vue, axios, common, jssdk, MINT) {

    Vue.component(MINT.Toast.name, MINT.Toast);

    var vm = new Vue({
        el: "#view",
        data: {
            keyword: "",
            ci: []
        },
        mounted: function () {
            var self = this;
        },
        methods: {
            query: function () {
                if (common.isEmpty(this.keyword)) {
                    MINT.Toast("请输入查询条件");
                    return;
                }

                var self = this;

                axios.get("equipment/query?keyword=" + this.keyword)
                    .then(function (response) {
                        self.ci = response.data;
                    });
            },
            scan: function () {
                var self = this;
                jssdk.scan(function (code) {
                    self.keyword = code;
                    self.query();
                });
            },
            gotoDetail: function (id) {
                window.location.href = "equipmentDetail.html?id=" + id;
            }
        }
    });
});